import '../index.dart';
import 'package:flutter_picker/flutter_picker.dart';

class PickerUtil {
  static void showModalPicker(
    BuildContext context, {
    required PickerAdapter adapter,
    String? title,
    List<int>? selecteds,
    required PickerConfirmCallback onConfirm,
  }) {
    FocusScope.of(context).unfocus();

    Picker(
            adapter: adapter,
            title: Text(
              title ?? "请选择",
              style: Theme.of(context).textTheme.titleMedium,
            ),
            selecteds: selecteds,
            cancelText: '取消',
            confirmText: "确定",
            cancelTextStyle: Theme.of(context).textTheme.bodyMedium,
            confirmTextStyle: Theme.of(context)
                .textTheme
                .bodyMedium
                ?.copyWith(color: Theme.of(context).primaryColor),
            textAlign: TextAlign.right,
            itemExtent: 44.0,
            height: MediaQuery.of(context).size.height / 3,
            backgroundColor: Theme.of(context).colorScheme.background,
            textStyle: Theme.of(context).textTheme.bodyMedium,
            selectedTextStyle: Theme.of(context).textTheme.bodyMedium,
            onConfirm: onConfirm)
        .showModal(context);
  }
}
